﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace QQinfo
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("输入账号");
            string username = Console.ReadLine();
            Console.WriteLine("输入密码");
            string password = Console.ReadLine();

            // Login
            int flag = Login(username,password);
            if (flag == 0)
            {

            }
            else if (flag == 1)
            {


            }
            else {
                
            }
            Console.ReadLine();
        }

        private static int Login(string username, string password)
        {
            string str = "Data Source=101.35.146.248;Initial Catalog=s1;Persist Security Info=True;User ID=sa;Password=123456@qwe";
            SqlConnection connection = new SqlConnection(str);
            connection.Open();
            string sql = "select * from sys_user where username = '" + username + "' and password = '" + password + "'";
            SqlCommand command = new SqlCommand(sql, connection);
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                return (int)reader["isadmin"];
                //if ((string)reader["isadmin"] == "1")
                //{
                //    Console.WriteLine("打印管理员菜单");
                //    // printAdmin
                //}
                //else
                //{
                //    Console.WriteLine("普通用户菜单");
                //    // printCommon
                //}
            }
            return -1;
        }
    }
}
